﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.XPath;

namespace PropertySetter
{
    public enum ModelingMethod
    {
        Interactive,
        Script
    }
    public enum ScriptLanguage
    {
        CSharp,
        Javascript
    }
    public enum CmdDataType
    {
        Float,
        Integer,
        Boolean,
        String,
        Vector2,
        Vector3,
        Matrix4,
        Curve2,
        Shape2,
        Line3,
        Plane,
        Solid
    }
    public class CommandArgument
    {
        public string Name;
        public string DisplayName;
        public CmdDataType DataType;
        public bool IsArray;
        public object DefaultValue;
        public string HelpInfo;
    }
    public class CommandValue
    {
        public string Expression; //"e:xxx+yyy+@arg"
        public string ArgumentName;//"@arg"
        public object Value;
    }
    public enum CmdResultNumber
    {
        None,
        One,
        Two,
        Multi
    }
 
    public class InteractiveCommand 
    {
        public string Name;
        public List<CommandArgument> Args ;
        
        public CmdResultNumber ResultNumber;
        public  List<CmdDataType> ResultTypes;

        public string DisplayName;
        public string HelpInfo;
    }
 
    public class ParameterDefinition { }
    public class LibraryComponent
    {
        public string Uuid;
        public string Namespace;
        public string Category;
        public string SubCategory;
        public string Description;
        public string Company;
        public string Author;
        public string Version;

        public ParameterDefinition Parameters;
        public ModelingMethod Method;
        public List<InteractiveCommand> Commands;
        public ScriptLanguage Language;
        public string ScriptBody;

        public List<object> GetCurve2ds(object paramValues)
        {
            return null;
        }
        public List<object> GetSolid3ds(object paramValues)
        {
            return null;
        }
    }
    public class LibraryComponentManager
    {
        public static Dictionary<string, object> LibraryComponents = new Dictionary<string, object>();

    }


    
    public static class Draw2dCommands
    {
        public static InteractiveCommand LINE = new InteractiveCommand
        {

        };
        public static InteractiveCommand ARC = new InteractiveCommand
        {

        }; 
        public static InteractiveCommand ELLIPSEARC = new InteractiveCommand
        {

        };
        public static InteractiveCommand SHAPE = new InteractiveCommand
        {

        }; 
        public static InteractiveCommand HOLE = new InteractiveCommand
        {

        };

        public static InteractiveCommand RECT = new InteractiveCommand
        {

        };

        
        public static InteractiveCommand CIRCLE = new InteractiveCommand
        {

        };
        public static InteractiveCommand ELLIPSE = new InteractiveCommand
        {

        };
        public static InteractiveCommand UNION2 = new InteractiveCommand
        {

        };
        public static InteractiveCommand DIFFER2 = new InteractiveCommand
        {

        };
        public static InteractiveCommand INTERSECT2 = new InteractiveCommand
        {

        };
    }

    public static class Modeling3dCommands
    {
        public static InteractiveCommand LINE3 = new InteractiveCommand
        {

        };
        public static InteractiveCommand Curve3 = new InteractiveCommand
        {
            Args = new List<CommandArgument>()
             {
                 new CommandArgument()
                 {
                      Name="LocalCS3",
                      DisplayName="局部坐标系",
                      DataType= CmdDataType.Matrix4
                 },
                 new CommandArgument()
                 {
                      Name="Curve2",
                      DisplayName="二维曲线",
                      DataType= CmdDataType.Curve2
                 }
             }
        };

        public static InteractiveCommand CUBE = new InteractiveCommand
        {

        }; 
        public static InteractiveCommand CUBIC = new InteractiveCommand
        {

        };
        public static InteractiveCommand UNION3 = new InteractiveCommand
        {

        };
        public static InteractiveCommand DIFFER3 = new InteractiveCommand
        {

        };
        public static InteractiveCommand INTERSECT3 = new InteractiveCommand
        {

        };
    }

    public static class ProgCommands
    {
        public static InteractiveCommand IF = new InteractiveCommand
        {
            Args = new List<CommandArgument>()
             {
                 new CommandArgument()
                 {
                      Name="Condition",
                      DisplayName="条件",
                      DataType= CmdDataType.Boolean
                 }
             }
        };
        public static InteractiveCommand ELSE = new InteractiveCommand
        {

        };
        public static InteractiveCommand ENDIF = new InteractiveCommand
        {

        };
        public static InteractiveCommand FOR = new InteractiveCommand
        {
            DisplayName="步进循环",
            Args = new List<CommandArgument>()
            {
                new CommandArgument()
                {
                    Name = "Start",
                    DisplayName = "开始",
                    DataType = CmdDataType.Integer
                },
                new CommandArgument()
                {
                    Name = "End",
                    DisplayName = "结束",
                    DataType = CmdDataType.Integer
                },
                new CommandArgument()
                {
                    Name = "Step",
                    DisplayName = "步进",
                    DataType = CmdDataType.Integer
                },
            },
            ResultNumber = CmdResultNumber.One,//返回索引
            ResultTypes = new List<CmdDataType> { CmdDataType.Integer }
        };
        public static InteractiveCommand ENDFOR= new InteractiveCommand
        {

        };

        public static InteractiveCommand WHILE = new InteractiveCommand
        {
             DisplayName="条件循环",
            Args = new List<CommandArgument>()
             {
                 new CommandArgument()
                 {
                      Name="Condition",
                      DisplayName="条件",
                      DataType= CmdDataType.Boolean
                 }
             }
        };
        public static InteractiveCommand ENDWHILE = new InteractiveCommand
        {

        };
        public static InteractiveCommand RETURN = new InteractiveCommand
        {
            DisplayName = "返回结果",
            Args = new List<CommandArgument>()
             {
                 new CommandArgument()
                 {
                      Name="Curves",
                      DisplayName="线条数组",
                      DataType= CmdDataType.Curve2,
                       IsArray=true
                 },
                 new CommandArgument()
                 {
                      Name="Solids",
                      DisplayName="实体数组",
                      DataType= CmdDataType.Solid,
                       IsArray=true
                 }
             }
        };
    }


}


/*
 * V2=Vector2 V3=Vector3 A =Array
 条件IF(@A)
var R1=Arc(V2(9,0),V3(),A(100,10),100);
var R2=Extend(R1,100);
Move(R2,100,100);
Rotate(R2,90);
条件结束;
条件IF(！)
EIFN；

*/